﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Collections;
using TS_XY_Train_Repaire.UserCon.SysSetting;

namespace TS_XY_Train_Repaire.SysSetting
{
    public partial class Sys_Settings_Tree_Level_Main_ManaFrom : DevExpress.XtraEditors.XtraForm
    {
        public Sys_Settings_Tree_Level_Main_ManaFrom()
        {
            InitializeComponent();
        }
        private void Sys_Settings_Tree_Level_Main_ManaFrom_Load(object sender, EventArgs e)
        {
            _LoadTreeList();
        }

        private void Sys_Settings_Tree_Level_Main_ManaFrom_FormClosing(object sender, FormClosingEventArgs e)
        {
            TS_Win_Locomotive_MainForm.htActionItem.Remove(this.Name);
        }
        #region//--系统目录事件--//
        private void _LoadTreeList()
        {
            tl_Level.Nodes.Clear();
            DataTable _dt = new DataTable();
            tl_Tree.Nodes.Clear();
            tl_Tree.Refresh();
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            ArrayList pList = new ArrayList();
            _ls = new LeverString_SysTreeMainList();
            _ls.f_id = "M-1";
            _ls.f_name = "系统底层数据目录";
            _ls.f_imgindex = 4;
            pList.Add(_ls);
            try
            {
                string strSQL = "select * from TS_S_T_P_Tree_Main where f_deep=0 and f_del=0";
                SqlConnection conn = new SqlConnection(TS_Win_Class.GetSQlConnStr());
                conn.Open();
                SqlCommand cmd = new SqlCommand(strSQL, conn);
                SqlDataReader read = cmd.ExecuteReader();
                string _strUPID = "and (";
                int i = 0;
                while (read.Read())
                {
                    _ls = new LeverString_SysTreeMainList();
                    _ls.f_id = "T" + read["f_id"].ToString();
                    _ls.f_name = read["f_name"].ToString();
                    _ls.f_parent = "M-1";
                    _ls.f_deep = read["f_deep"].ToString();
                    _ls.f_level = read["f_level"].ToString();
                    _ls.f_type = read["f_type"].ToString();
                    _ls.f_str_0 = read["f_str_0"].ToString();
                    _ls.f_str_1 = read["f_str_1"].ToString();
                    _ls.f_str_2 = read["f_str_2"].ToString();
                    _ls.f_func_0 = read["f_func_0"].ToString();
                    _ls.f_func_1 = read["f_func_1"].ToString();
                    _ls.f_func_2 = read["f_func_2"].ToString();
                    if (read["f_type"].ToString() == "0")
                    {
                        _ls.f_imgindex = 5;
                    }
                    else
                    {
                        _ls.f_imgindex = 6;
                    }
                    if (i == 0)
                    {
                        _strUPID += "(f_level like '%," + read["f_id"].ToString() + ",%')";
                    }
                    else
                    {
                        _strUPID += "or (f_level like '%," + read["f_id"].ToString() + ",%')";
                    }
                    pList.Add(_ls);
                    i++;
                }
                _strUPID += ")";
                if (_strUPID.Length > 7)
                {
                    read.Close();
                    strSQL = "select * from TS_S_T_P_Tree_Main where f_deep>0 and f_del=0 " + _strUPID + " order by f_deep,f_level,f_name asc";
                    cmd = new SqlCommand(strSQL, conn);
                    read = cmd.ExecuteReader();
                    string _UPID = "";
                    while (read.Read())
                    {
                        _ls = new LeverString_SysTreeMainList();
                        _ls.f_id = "T" + read["f_id"].ToString();
                        _ls.f_name = read["f_name"].ToString();
                        _ls.f_deep = read["f_deep"].ToString();
                        _ls.f_level = read["f_level"].ToString();
                        _ls.f_type = read["f_type"].ToString();
                        _ls.f_str_0 = read["f_str_0"].ToString();
                        _ls.f_str_1 = read["f_str_1"].ToString();
                        _ls.f_str_2 = read["f_str_2"].ToString();
                        _ls.f_func_0 = read["f_func_0"].ToString();
                        _ls.f_func_1 = read["f_func_1"].ToString();
                        _ls.f_func_2 = read["f_func_2"].ToString();
                        _UPID = read["f_level"].ToString();
                        _UPID = _UPID.Substring(0, _UPID.Length - 1);
                        _UPID = _UPID.Substring(_UPID.LastIndexOf(',') + 1);
                        _ls.f_parent = "T" + _UPID;
                        if (read["f_type"].ToString() == "0")
                        {
                            _ls.f_imgindex = 5;
                        }
                        else
                        {
                            _ls.f_imgindex = 6;
                        }
                        pList.Add(_ls);
                    }
                }
                read.Close();
                conn.Close();
                conn.Dispose();
            }
            catch
            {
            }
            tl_Tree.DataSource = pList;
        }
        private void bbi_Tree_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Tree_ManaForm _uc = new uc_Sys_Settings_Tree_ManaForm();
            _uc._tl = _ls;
            _uc._LoadType = "Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadTreeList();
                tl_Tree.SetFocusedNode(tl_Tree.FindNodeByFieldValue("f_id", _ls.f_id));
            }
            else
            {
            }
        }

        private void bbi_Tree_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Sys_Settings_Tree_ManaForm _uc = new uc_Sys_Settings_Tree_ManaForm();
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            _uc._tl = _ls;
            _uc._LoadType = "Edit";
            //_uc.Tag = _ls;
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadTreeList();
                tl_Tree.SetFocusedNode(tl_Tree.FindNodeByFieldValue("f_id", _ls.f_id));
            }
            else
            {
            }
        }

        private void bbi_Tree_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "-1";
            try
            {
                _UpID = tl_Tree.FocusedNode.ParentNode["f_id"].ToString();
            }
            catch
            { }

            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Tree_ManaForm _uc = new uc_Sys_Settings_Tree_ManaForm();
            _uc._tl = _ls;
            _uc._LoadType = "Del";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadTreeList();
                tl_Tree.SetFocusedNode(tl_Tree.FindNodeByFieldValue("f_id", _UpID));
            }
            else
            {
            }
        }

        private void tl_Tree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            bbi_Tree_Add.Enabled = false;
            bbi_Tree_Edit.Enabled = false;
            bbi_Tree_Del.Enabled = false;
            bbi_Level_Add.Enabled = false;
            bbi_Level_Sub_Add.Enabled = false;
            bbi_Level_Edit.Enabled = false;
            bbi_Level_Del.Enabled = false;
            try
            {
                if (tl_Tree.FocusedNode["f_id"].ToString().Substring(0, 1) == "M")
                {
                    bbi_Tree_Add.Enabled = true;
                }
                else if (tl_Tree.FocusedNode["f_id"].ToString().Substring(0, 1) == "T")
                {
                    bbi_Tree_Add.Enabled = true;
                    bbi_Tree_Edit.Enabled = true;
                    bbi_Tree_Del.Enabled = true;
                    if (tl_Tree.FocusedNode["f_type"].ToString() == "1")
                    {
                        bbi_Level_Add.Enabled = true;
                    }
                }
            }
            catch
            {
            }
        }

        private void tl_Tree_DoubleClick(object sender, EventArgs e)
        {
            f_func_0.Visible = false;
            f_func_1.Visible = false;
            f_func_2.Visible = false;
            f_str_0.Visible = false;
            f_str_1.Visible = false;
            f_str_2.Visible = false;
            if (tl_Tree.FocusedNode["f_type"].ToString() == "1")
            {
                if (tl_Tree.FocusedNode["f_str_0"].ToString() != "-")
                {
                    f_str_0.Visible = true;
                    f_str_0.Caption = tl_Tree.FocusedNode["f_str_0"].ToString();
                }
                if (tl_Tree.FocusedNode["f_str_1"].ToString() != "-")
                {
                    f_str_1.Visible = true;
                    f_str_1.Caption = tl_Tree.FocusedNode["f_str_1"].ToString();
                }
                if (tl_Tree.FocusedNode["f_str_2"].ToString() != "-")
                {
                    f_str_2.Visible = true;
                    f_str_2.Caption = tl_Tree.FocusedNode["f_str_2"].ToString();
                }
                if (tl_Tree.FocusedNode["f_func_0"].ToString() != ",")
                {
                    f_func_0.Visible = true;
                    f_func_0.Caption = tl_Tree.FocusedNode["f_func_0"].ToString().Split(',')[0];
                }
                if (tl_Tree.FocusedNode["f_func_1"].ToString() != ",")
                {
                    f_func_1.Visible = true;
                    f_func_1.Caption = tl_Tree.FocusedNode["f_func_1"].ToString().Split(',')[0];
                }
                if (tl_Tree.FocusedNode["f_func_2"].ToString() != ",")
                {
                    f_func_2.Visible = true;
                    f_func_2.Caption = tl_Tree.FocusedNode["f_func_2"].ToString().Split(',')[0];
                }
            }
            _LoadLevelList();
        }
        #endregion
        #region//--目录数据事件--//
        private void _LoadLevelList()
        {
            tl_Level.Nodes.Clear();
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            ArrayList pList = new ArrayList();
            try
            {
                if (tl_Tree.FocusedNode["f_id"].ToString().Substring(0, 1) == "T" && tl_Tree.FocusedNode["f_type"].ToString() == "1")
                {
                    string strSQL = "select * from TS_S_T_P_Tree where f_mainid=" + tl_Tree.FocusedNode["f_id"].ToString().Substring(1) + " and f_deep=0 and f_del=0";
                    SqlConnection conn = new SqlConnection(TS_Win_Class.GetSQlConnStr());
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(strSQL, conn);
                    SqlDataReader read = cmd.ExecuteReader();
                    string _strUPID = "and (";
                    int i = 0;
                    while (read.Read())
                    {
                        _ls = new LeverString_SysTreeMainList();
                        _ls.f_id = "L" + read["f_id"].ToString();
                        _ls.f_name = read["f_name"].ToString();
                        _ls.f_parent = "L-1";
                        _ls.f_code = read["f_code"].ToString();
                        _ls.f_mainid = read["f_mainid"].ToString();
                        _ls.f_deep = read["f_deep"].ToString();
                        _ls.f_level = read["f_level"].ToString();
                        _ls.f_type = read["f_type"].ToString();
                        _ls.f_str_0 = read["f_str_0"].ToString();
                        _ls.f_str_1 = read["f_str_1"].ToString();
                        _ls.f_str_2 = read["f_str_2"].ToString();
                        _ls.f_func_0 = read["f_func_0"].ToString();
                        _ls.f_func_1 = read["f_func_1"].ToString();
                        _ls.f_func_2 = read["f_func_2"].ToString();
                        if (read["f_type"].ToString() == "0")
                        {
                            _ls.f_imgindex = 5;
                        }
                        else
                        {
                            _ls.f_imgindex = 6;
                        }
                        if (i == 0)
                        {
                            _strUPID += "(f_level like '%," + read["f_id"].ToString() + ",%')";
                        }
                        else
                        {
                            _strUPID += "or (f_level like '%," + read["f_id"].ToString() + ",%')";
                        }
                        pList.Add(_ls);
                        i++;
                    }
                    _strUPID += ")";
                    if (_strUPID.Length > 7)
                    {
                        read.Close();
                        strSQL = "select * from TS_S_T_P_Tree where f_mainid=" + tl_Tree.FocusedNode["f_id"].ToString().Substring(1) + " and f_deep>0 and f_del=0 " + _strUPID + " order by f_deep,f_level,f_name asc";
                        cmd = new SqlCommand(strSQL, conn);
                        read = cmd.ExecuteReader();
                        string _UPID = "";
                        while (read.Read())
                        {
                            _ls = new LeverString_SysTreeMainList();
                            _ls.f_id = "L" + read["f_id"].ToString();
                            _ls.f_name = read["f_name"].ToString();
                            _ls.f_code = read["f_code"].ToString();
                            _ls.f_mainid = read["f_mainid"].ToString();
                            _ls.f_deep = read["f_deep"].ToString();
                            _ls.f_level = read["f_level"].ToString();
                            _ls.f_type = read["f_type"].ToString();
                            _ls.f_str_0 = read["f_str_0"].ToString();
                            _ls.f_str_1 = read["f_str_1"].ToString();
                            _ls.f_str_2 = read["f_str_2"].ToString();
                            _ls.f_func_0 = read["f_func_0"].ToString();
                            _ls.f_func_1 = read["f_func_1"].ToString();
                            _ls.f_func_2 = read["f_func_2"].ToString();
                            _UPID = read["f_level"].ToString();
                            _UPID = _UPID.Substring(0, _UPID.Length - 1);
                            _UPID = _UPID.Substring(_UPID.LastIndexOf(',') + 1);
                            _ls.f_parent = "L" + _UPID;
                            if (read["f_type"].ToString() == "0")
                            {
                                _ls.f_imgindex = 5;
                            }
                            else
                            {
                                _ls.f_imgindex = 6;
                            }
                            pList.Add(_ls);
                        }
                    }
                    read.Close();
                    conn.Close();
                    conn.Dispose();
                }
            }
            catch
            {
            }
            tl_Level.DataSource = pList;
        }
        private void bbi_Level_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Level_ManaForm _uc = new uc_Sys_Settings_Level_ManaForm();
            _uc._tl = _ls;
            _ls = new LeverString_SysTreeMainList();
            _ls.f_mainid = "Add";
            try
            {
                _ls.f_id = tl_Level.FocusedNode["f_id"].ToString();
                _ls.f_mainid = tl_Level.FocusedNode["f_mainid"].ToString();
                _ls.f_name = tl_Level.FocusedNode["f_name"].ToString();
                _ls.f_code = tl_Level.FocusedNode["f_code"].ToString();
                _ls.f_deep = tl_Level.FocusedNode["f_deep"].ToString();
                _ls.f_level = tl_Level.FocusedNode["f_level"].ToString();
                _ls.f_type = tl_Level.FocusedNode["f_type"].ToString();
                _ls.f_str_0 = tl_Level.FocusedNode["f_str_0"].ToString();
                _ls.f_str_1 = tl_Level.FocusedNode["f_str_1"].ToString();
                _ls.f_str_2 = tl_Level.FocusedNode["f_str_2"].ToString();
                _ls.f_func_0 = tl_Level.FocusedNode["f_func_0"].ToString();
                _ls.f_func_1 = tl_Level.FocusedNode["f_func_1"].ToString();
                _ls.f_func_2 = tl_Level.FocusedNode["f_func_2"].ToString();
            }
            catch
            {
            }
            _uc._ll = _ls;
            _uc._LoadType = "Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadLevelList();
                tl_Level.SetFocusedNode(tl_Level.FindNodeByFieldValue("f_id", _uc._ll.f_id));
            }
            else
            {
            }
        }
        private void bbi_Level_Sub_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Level_ManaForm _uc = new uc_Sys_Settings_Level_ManaForm();
            _uc._tl = _ls;
            _ls = new LeverString_SysTreeMainList();
            try
            {
                _ls.f_id = tl_Level.FocusedNode["f_id"].ToString();
                _ls.f_mainid = tl_Level.FocusedNode["f_mainid"].ToString();
                _ls.f_name = tl_Level.FocusedNode["f_name"].ToString();
                _ls.f_code = tl_Level.FocusedNode["f_code"].ToString();
                _ls.f_deep = tl_Level.FocusedNode["f_deep"].ToString();
                _ls.f_level = tl_Level.FocusedNode["f_level"].ToString();
                _ls.f_type = tl_Level.FocusedNode["f_type"].ToString();
                _ls.f_str_0 = tl_Level.FocusedNode["f_str_0"].ToString();
                _ls.f_str_1 = tl_Level.FocusedNode["f_str_1"].ToString();
                _ls.f_str_2 = tl_Level.FocusedNode["f_str_2"].ToString();
                _ls.f_func_0 = tl_Level.FocusedNode["f_func_0"].ToString();
                _ls.f_func_1 = tl_Level.FocusedNode["f_func_1"].ToString();
                _ls.f_func_2 = tl_Level.FocusedNode["f_func_2"].ToString();
            }
            catch
            {
            }
            _uc._ll = _ls;
            _uc._LoadType = "Sub_Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadLevelList();
                tl_Level.SetFocusedNode(tl_Level.FindNodeByFieldValue("f_id", _uc._ll.f_id));
            }
            else
            {
            }
        }
        private void bbi_Level_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Level_ManaForm _uc = new uc_Sys_Settings_Level_ManaForm();
            _uc._tl = _ls;
            _ls = new LeverString_SysTreeMainList();
            try
            {
                _ls.f_id = tl_Level.FocusedNode["f_id"].ToString();
                _ls.f_mainid = tl_Level.FocusedNode["f_mainid"].ToString();
                _ls.f_name = tl_Level.FocusedNode["f_name"].ToString();
                _ls.f_code = tl_Level.FocusedNode["f_code"].ToString();
                _ls.f_deep = tl_Level.FocusedNode["f_deep"].ToString();
                _ls.f_level = tl_Level.FocusedNode["f_level"].ToString();
                _ls.f_type = tl_Level.FocusedNode["f_type"].ToString();
                _ls.f_str_0 = tl_Level.FocusedNode["f_str_0"].ToString();
                _ls.f_str_1 = tl_Level.FocusedNode["f_str_1"].ToString();
                _ls.f_str_2 = tl_Level.FocusedNode["f_str_2"].ToString();
                _ls.f_func_0 = tl_Level.FocusedNode["f_func_0"].ToString();
                _ls.f_func_1 = tl_Level.FocusedNode["f_func_1"].ToString();
                _ls.f_func_2 = tl_Level.FocusedNode["f_func_2"].ToString();
            }
            catch
            {
            }
            _uc._ll = _ls;
            _uc._LoadType = "Edit";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadLevelList();
                tl_Level.SetFocusedNode(tl_Level.FindNodeByFieldValue("f_id", _uc._ll.f_id));
            }
            else
            {
            }
        }

        private void bbi_Level_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "-1";
            try
            {
                _UpID = tl_Level.FocusedNode.ParentNode["f_id"].ToString();
            }
            catch
            { }
            LeverString_SysTreeMainList _ls = new LeverString_SysTreeMainList();
            _ls.f_id = tl_Tree.FocusedNode["f_id"].ToString();
            _ls.f_name = tl_Tree.FocusedNode["f_name"].ToString();
            _ls.f_deep = tl_Tree.FocusedNode["f_deep"].ToString();
            _ls.f_level = tl_Tree.FocusedNode["f_level"].ToString();
            _ls.f_type = tl_Tree.FocusedNode["f_type"].ToString();
            _ls.f_str_0 = tl_Tree.FocusedNode["f_str_0"].ToString();
            _ls.f_str_1 = tl_Tree.FocusedNode["f_str_1"].ToString();
            _ls.f_str_2 = tl_Tree.FocusedNode["f_str_2"].ToString();
            _ls.f_func_0 = tl_Tree.FocusedNode["f_func_0"].ToString();
            _ls.f_func_1 = tl_Tree.FocusedNode["f_func_1"].ToString();
            _ls.f_func_2 = tl_Tree.FocusedNode["f_func_2"].ToString();
            uc_Sys_Settings_Level_ManaForm _uc = new uc_Sys_Settings_Level_ManaForm();
            _uc._tl = _ls;
            _ls = new LeverString_SysTreeMainList();
            try
            {
                _ls.f_id = tl_Level.FocusedNode["f_id"].ToString();
                _ls.f_mainid = tl_Level.FocusedNode["f_mainid"].ToString();
                _ls.f_name = tl_Level.FocusedNode["f_name"].ToString();
                _ls.f_code = tl_Level.FocusedNode["f_code"].ToString();
                _ls.f_deep = tl_Level.FocusedNode["f_deep"].ToString();
                _ls.f_level = tl_Level.FocusedNode["f_level"].ToString();
                _ls.f_type = tl_Level.FocusedNode["f_type"].ToString();
                _ls.f_str_0 = tl_Level.FocusedNode["f_str_0"].ToString();
                _ls.f_str_1 = tl_Level.FocusedNode["f_str_1"].ToString();
                _ls.f_str_2 = tl_Level.FocusedNode["f_str_2"].ToString();
                _ls.f_func_0 = tl_Level.FocusedNode["f_func_0"].ToString();
                _ls.f_func_1 = tl_Level.FocusedNode["f_func_1"].ToString();
                _ls.f_func_2 = tl_Level.FocusedNode["f_func_2"].ToString();
            }
            catch
            {
            }
            _uc._ll = _ls;
            _uc._LoadType = "Del";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadLevelList();
                tl_Level.SetFocusedNode(tl_Level.FindNodeByFieldValue("f_id", _UpID));
            }
            else
            {
            }
        }

        private void tl_Level_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            bbi_Level_Sub_Add.Enabled = false;
            bbi_Level_Edit.Enabled = false;
            bbi_Level_Del.Enabled = false;
            bbi_Level_Auth.Enabled = false;
            bbi_Level_Rel.Enabled = false;
            try
            {
                if (tl_Level.FocusedNode["f_id"].ToString().Substring(0, 1) == "L")
                {
                    bbi_Level_Sub_Add.Enabled = true;
                    bbi_Level_Edit.Enabled = true;
                    bbi_Level_Del.Enabled = true;
                    if (tl_Level.FocusedNode["f_type"].ToString() == "1")
                    {
                        bbi_Level_Auth.Enabled = true;
                        bbi_Level_Rel.Enabled = true;
                    }
                }
            }
            catch
            {
            }
        }

        private void tl_Level_DoubleClick(object sender, EventArgs e)
        {

        }

        private void bbi_Level_Auth_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Sys_Settings_Level_Auth_ManaForm _uc = new uc_Sys_Settings_Level_Auth_ManaForm();
            _uc._LoadID = tl_Level.FocusedNode["f_id"].ToString();
            _uc._LoadName = tl_Level.FocusedNode["f_name"].ToString();
            _uc.ShowDialog();
        }

        private void bbi_Level_Rel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

        #endregion
        private void bbi_Reload_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "0";
            try
            {
                _UpID = tl_Tree.FocusedNode["f_id"].ToString();
            }
            catch
            {
            }
            _LoadTreeList();
            try
            {
                tl_Tree.SetFocusedNode(tl_Tree.FindNodeByFieldValue("f_id", _UpID));
            }
            catch
            {
            }
        }
    }
}